
package gameserver.network.factories;


import gameserver.network.loginserver.LoginServerConnection.State;
import gameserver.network.loginserver.LsClientPacket;
import gameserver.network.loginserver.LsPacketHandler;
import gameserver.network.loginserver.clientpackets.*;

/**
 * @author Luno
 */
public class LsPacketHandlerFactory {
    private LsPacketHandler handler = new LsPacketHandler();

    public static final LsPacketHandlerFactory getInstance() {
        return SingletonHolder.instance;
    }

    /**
     * @param loginServer
     */
    private LsPacketHandlerFactory() {

        addPacket(new CM_ACCOUNT_RECONNECT_KEY(0x03), State.AUTHED);
        addPacket(new CM_ACOUNT_AUTH_RESPONSE(0x01), State.AUTHED);
        addPacket(new CM_GS_AUTH_RESPONSE(0x00), State.CONNECTED);
        addPacket(new CM_REQUEST_KICK_ACCOUNT(0x02), State.AUTHED);
        addPacket(new CM_LS_CONTROL_RESPONSE(0x04), State.AUTHED);
        addPacket(new CM_BAN_RESPONSE(0x05), State.AUTHED);
		addPacket(new CM_MACBAN_LIST(0x09), State.AUTHED);
		addPacket(new CM_MACBAN_REQUEST_MAC(0x10), State.AUTHED);
        addPacket(new CM_LS_REQUEST_CHARACTER_COUNT(0x06), State.AUTHED);

    }

    private void addPacket(LsClientPacket prototype, State... states) {
        handler.addPacketPrototype(prototype, states);
    }

    public LsPacketHandler getPacketHandler() {
        return handler;
    }

    @SuppressWarnings("synthetic-access")
    private static class SingletonHolder {
        protected static final LsPacketHandlerFactory instance = new LsPacketHandlerFactory();
    }
}
